<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla view library
jimport('joomla.application.component.view');
 
/**
 * HTML View class for the Component
 */
class MariagePlannerViewTask extends JView
{
	protected $state;
	protected $form;
	protected $item;
	protected $user;
	
	// Overwriting JView display method
	function display($tpl = null) 
	{ 
		$app		= JFactory::getApplication();
		$user		= JFactory::getUser();
		
		$this->item		= $this->get('Item');
		$this->state	= $this->get('State');
		$this->user 	= $user;
		$this->form		= $this->get('Form');
		$this->script 	= $this->get('Script');
		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		
		$session	= JFactory::getSession();
		$this->assignRef('session', $session);
		
		// Display the view
		parent::display($tpl);
		
		// Set the document
		$this->setDocument();
	}
	
	/**
	 * Method to set up the document properties
	 *
	 * @return void
	 */
	protected function setDocument()
	{
		$isNew = ($this->item->id < 1);
		$document = JFactory::getDocument();
		$document->setTitle($isNew ? JText::_('COM_MARIAGEPLANNER_TASK_CREATING')
				: JText::_('COM_MARIAGEPLANNER_TASK_EDITING'));
		$document->addScript(JURI::root() . $this->script);
		$document->addScript(JURI::root() . "/components/com_mariageplanner"
				. "/js/submitbutton.js");
		JText::script('COM_MARIAGEPLANNER_FIELD_ERROR_UNACCEPTABLE');
	}	
}
?>